package com.jhd.fuzhou.view.archive;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.jhd.fuzhou.view.login.BaseActivity;
import com.jhd.fuzhou.R;
import com.jhd.fuzhou.vo.ArchivesVo;

import net.zigin.commons.util.StringUtil;

import butterknife.BindView;
import butterknife.OnClick;

public class ArchiveDetailActivity extends BaseActivity {
    private ArchivesVo archivesVo;
    @BindView(R.id.rel_document)RelativeLayout rel_document;
    @BindView(R.id.tv_type)TextView tv_type;
    @BindView(R.id.tv_name)TextView tv_name;
    @BindView(R.id.tv_belong_dept)TextView tv_belong_dept;
    @BindView(R.id.tv_number)TextView tv_number;
    @BindView(R.id.tv_source)TextView tv_source;
    @BindView(R.id.tv_secrecy_level)TextView tv_secrecy_level;
    @BindView(R.id.tv_keep_dept)TextView tv_keep_dept;
    @BindView(R.id.tv_status)TextView tv_status;
    @BindView(R.id.tv_keep_term)TextView tv_keep_term;
    @BindView(R.id.tv_fileDate)TextView tv_fileDate;
    @BindView(R.id.tv_archivesStock)TextView tv_archivesStock;
    @BindView(R.id.tv_stockLocation)TextView tv_stockLocation;
    @BindView(R.id.tv_filePersonName)TextView tv_filePersonName;
    @BindView(R.id.tv_pageNum)TextView tv_pageNum;
    @BindView(R.id.tv_remark)TextView tv_remark;
    private Context context=this;

    @Override
    protected void loadViewLayout() {
        setContentView(R.layout.activity_archive_detail);
    }

    @Override
    protected void processLogic() {
        onBack();
        String data = getIntent().getStringExtra("data");
        archivesVo= JSON.parseObject(data, ArchivesVo.class);
        if(archivesVo!=null){
            setData();
        }
    }
    private void setData(){
        tv_type.setText(StringUtil.isNullOrEmpty(archivesVo.getArchivesTypeName())?"":archivesVo.getArchivesTypeName());
        tv_name.setText(StringUtil.isNullOrEmpty(archivesVo.getArchivesName())?"":archivesVo.getArchivesName());
        tv_belong_dept.setText(StringUtil.isNullOrEmpty(archivesVo.getDeptName())?"":archivesVo.getDeptName());
        tv_number.setText(StringUtil.isNullOrEmpty(archivesVo.getArchivesNo())?"":archivesVo.getArchivesNo());
        tv_source.setText(StringUtil.isNullOrEmpty(archivesVo.getSource())?"":archivesVo.getSource());
        tv_secrecy_level.setText(StringUtil.isNullOrEmpty(archivesVo.getSecrecyLevel())?"":archivesVo.getSecrecyLevel());
        tv_keep_dept.setText(StringUtil.isNullOrEmpty(archivesVo.getSafekeepDeptName())?"":archivesVo.getSafekeepDeptName());
        //(0-销毁 1-正常 2-删除)
        if(!StringUtil.isNullOrEmpty(archivesVo.getStatus())){
            if("0".equals(archivesVo.getStatus())){
                tv_status.setText("销毁");
            }else if("1".equals(archivesVo.getStatus())){
                tv_status.setText("正常");
            }else if("2".equals(archivesVo.getStatus())){
                tv_status.setText("删除");
            }
        }
        tv_keep_term.setText(StringUtil.isNullOrEmpty(archivesVo.getSafekeepTerm())?"":archivesVo.getSafekeepTerm());
        tv_fileDate.setText((archivesVo.getFileDate()).substring(0,10));
        tv_archivesStock.setText(StringUtil.isNullOrEmpty(archivesVo.getArchivesStock())?"":archivesVo.getArchivesStock());
        tv_stockLocation.setText(StringUtil.isNullOrEmpty(archivesVo.getStockLocation())?"":archivesVo.getStockLocation());
        tv_filePersonName.setText(StringUtil.isNullOrEmpty(archivesVo.getFilePersonName())?"":archivesVo.getFilePersonName());
        tv_pageNum.setText(""+archivesVo.getPageNum());
        tv_remark.setText(StringUtil.isNullOrEmpty(archivesVo.getRemark())?"":archivesVo.getRemark());
    }
    @OnClick({R.id.rel_document})
    public void onClick(View v){
        switch (v.getId()){
            case R.id.rel_document:
                Intent intent=new Intent(context,ArchiveDocumentActivity.class);
                intent.putExtra("id",archivesVo.getId());
                startActivity(intent);
                break;
        }
    }
}